<?php
	$path_one = 'admin/admin_project';
	$path_two = 'admin/admin_project_address';
	$filename = 'admin/admin_project_address_add';
	require_once("header.php");
	require_once("admin_comm.php");
	require_once $_site->get_handlepath('project');
	require_once $_site->get_handlepath('admin');
	$id= request('id',false,true);
	$result = project_fun_get_project_address_info($id);
	$project_info = $result?project_fun_get_project_info($result['pid']):false;
?>
<script type="text/javascript" charset="utf-8">

	loader.file({
		plugin:['validform/main','dialog/main','my97/wdatepicker'],
		skincss:['list'],
		js:['coord']
	});
	$(document).ready(function(){

		var form_obj=$("#form1").Validform({
		   tiptype: function(msg, o, cssctl){
			   if(!o.obj.is("form")){
				   var obj = o.obj.parent("td").find('tt');
				   cssctl(obj, o.type);
				   obj.text(msg);
			   }
		   },
		   datatype:{
			   "cood": /^([0-9]{1,3}|[0-9]{1,3}\.[0-9]{0,10}),([0-9]{1,3}|[0-9]{1,3}\.[0-9]{0,10})$/
		   }
		   ,

		   ajaxPost:true,
		   callback:function (data){
				dialog.finish({
					content:data.msg,
					success:data.state,
					/*timeout:10000000,*/
					callback:function (){

						if(data.state){
							window.location.href='/admin/admin_project_address_list'
						}

					}
				})
		   }
		})
	})
	function get_project_info (){
		dialog.iframe({
			title:'项目选择',
			is_resize:false,
			top:{
				is_show:true,
				btn_max:false,
				btn_min:false,
				btn_close:true,
				height:33,
				is_move:true
			},
			is_scroll:false,
			min_width:350,
			min_height:500,
			is_center:true,
			is_lock_back:false,
			content:'/admin/common_choise?callback=set_project_info&parm=state.1',
			name:'choise_project'
		});
	}
	//展开地图
	function coord_show(){
		$("#coord_iframe_tr").show();
		coord_obj.show();
		$("#coord_a_s").text("重新获取");
		$("#coord_a_h").show();
		return false;
	}
	//收起地图
	function coord_hide(){
		$("#coord_iframe_tr").hide();
		return false;
	}
	function set_project_info(id,title){
		if(id && title){
			$("#pid").val(id);
			$("#name_title").val(title);
		}
	}
</script>
</head>
<body>
	<div class="position_nav">你所在的当前位置：<?php echo $path_str;?> &gt; <?php echo $result['id']?'编辑项目作业点':'添加项目作业点' ;?></div>
		<div class="main">
			<form action="/handle.php" method="post" id='form1'>
			<input type="hidden" name="h" value="project/address_add">
			<input type="hidden" name="id" value="<?php echo $result['id']?>">
			<table  cellpadding="0" cellspacing="1" border="0" class="table table_text">

				<tr>
					<td class="left">选择项目：</td>
					<td>
						<input type="hidden" name="pid" id='pid' value="<?php echo $result['pid'] ;?>" datatype='*' nullmsg='请选择项目'>
						<input type="text" class="w260" id='name_title' readonly="readonly" value="<?php echo $project_info['title'] ;?>" datatype='*' nullmsg='请选择项目'>
						<a href="javascript:get_project_info();">选择项目</a>
						<span class='comment'></span><tt></tt>
					</td>
				</tr>
				<tr>
					<td class="left">项目作业点名称：</td>
					<td>
						<input type="text" name='title' class="w260"id='address' value="<?php echo $result['title'] ;?>" datatype='*1-150' nullmsg='请填写项目作业点名称' errormsg='字符在1-150内'>
						<span class='comment'>该项目的实施详细地址或描述</span><tt></tt>
					</td>
				</tr>


				<tr>
					<td class="left">项目作业点坐标：</td>
					<td>
						<input type="text" nullmsg="请选择作业点坐标" datatype="cood" value="<?php echo $result?$result['coord_x'].','.$result['coord_y']:'' ;?>" name="coord" class="w260">
						<a id="coord_a_s" style="color: red" onClick="return coord_show();" href="#">获取坐标</a>
						<a onClick="coord_hide();return;" style="display: none;" id="coord_a_h" href="#">收起地图</a>
						<span class='comment'>点击获取坐标选取地图中地点，获取坐标，或手动输入坐标用英文,隔开如106.2358161111,30.1019521111</span><tt></tt>
					</td>
				</tr>
				<tr style="display: none;" id="coord_iframe_tr">
					<td></td>
					<td>
						<div style="width:700px;height:400px;" id="coord_iframe"></div>
					</td>
				</tr>
				<tr>
					<td class="left">作业地点范围：</td>
					<td>
						<input type="text" class="ipt1" name='distance' value="<?php echo $result['distance'] ;?>" datatype='int' nullmsg='请填写作业地点范围' errormsg='范围为整数米'> <span>米</span>
						<span class='comment'>作业地点范围，坐标半径范围内</span><tt></tt>
					</td>
				</tr>
				<tr>
					<td></td>
					<td>
						<input class="button1" type="submit" value="<?php echo $result['id']?'修改':'添加' ;?>">
					</td>
				</tr>

			</table>
			</form>
		</div>
	</div>
</body>
</html>





